<!--复制自member-update,重命名啊，测试完删除-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>更新订单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <link rel="stylesheet" href="../lib/layui257/css/layui.css"  media="all">
    <script type="text/javascript" src="js/xadmin.js"></script>
    <script src="../layui/layui.js"></script>
</head>
<body>
<div class="layui-form-item" style="margin-top: 60px">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-block">
        <input type="text" name="Pwd" id="Pwd" lay-verify="Pwd" autocomplete="off" placeholder="密码" class="layui-input" style="width: 75%">
    </div>
</div>
<div class="layui-form-item" >
    <label class="layui-form-label">电话</label>
    <div class="layui-input-block">
        <input type="text" name="Phone" id="Phone" lay-verify="Phone" autocomplete="off" placeholder="电话" class="layui-input" style="width: 75%">
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">地址</label>
    <div class="layui-input-block">
        <input type="text" name="Address" id="Address" lay-verify="Address" autocomplete="off" placeholder="地址" class="layui-input" style="width: 75%">
    </div>
</div>
<button class="layui-btn" style="margin-left: 40%" onclick="Commit()">提交</button>
<script>

    var index;//保存layuiEditID
    $(function () {

        $.ajax({
            url: 'http://localhost:8081/User/getUserList',//请求地址
            dataType: 'JSON',//值类型
            data: {
                page:1,
                limit:1,
                id:'',
                UName:'',
                Pwd:'',
               Address: '',
                Phone:''
            },//往后端发送的值
            success: function (res) {//成功的回调函数
                console.log(res.data)
                $("#id").val(localStorage.getItem("id"))
                $("#UName").val(res.data[0].UName)
                $("#Pwd").val(res.data[0].Pwd)
                $("#Phone").val(res.data[0].Phone)
                $("#Address").val(res.data[0].Address)
            },
            error: function (data) {//失败的回调函数
                layer.alert("系统出错");
            }
        })

    })

    function Commit() {//提交数据
        var layedit = layui.layedit;
        $.ajax({
            url: 'http://localhost:8081/Prevenient/addPrevenient',//请求地址
            dataType: 'JSON',//值类型,
            deliveryWay:'GET',
            data: {
                Pwd:$("#Pwd").val(),
                Phone:$("#Phone").val(),
                Address:$("#Address").val()
            },//往后端发送的值
            success: function (res) {//成功的回调函数
                if (res.code == "0") {
                    layer.alert("数据添加成功!")
                } else {
                    layer.alert("数据添加失败！")
                }
            },
            error: function (data) {//失败的回调函数
                layer.alert("系统出错");
            }
        })
        $.ajax({
            url: 'http://localhost:8081/User/upUser',//请求地址
            dataType: 'JSON',//值类型,
            deliveryWay:'GET',
            data: {
                id:localStorage.getItem("id"),
                UName:$("#UName").val(),
                Pwd:$("#Pwd").val(),
                Phone:$("#Phone").val(),
                Address:$("#Address").val(),
            },//往后端发送的值
            success: function (res) {//成功的回调函数
                if (res.code == "0") {
                    layer.alert("修改成功!")
                } else {
                    layer.alert("修改失败！")
                }
            },
            error: function (data) {//失败的回调函数
                layer.alert("系统出错");
            }
        })
    }
</script>
</body>
</html>